package com.pointstar.dp.modules.project.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.pointstar.dp.common.entity.Page;
import com.pointstar.dp.common.entity.Query;
import com.pointstar.dp.common.entity.R;
import com.pointstar.dp.common.utils.CommonUtils;
import com.pointstar.dp.modules.project.entity.OutBoundDetailsEntity;
import com.pointstar.dp.modules.project.dao.OutBoundDetailsMapper;
import com.pointstar.dp.modules.project.service.OutBoundDetailsService;

/**
 * 出库明细表
 * @author Korey<m13057531285@163.com>
 */
@Service("outBoundDetailsService")
public class OutBoundDetailsServiceImpl implements OutBoundDetailsService {

	private final OutBoundDetailsMapper outBoundDetailsMapper;

	@Autowired
	public OutBoundDetailsServiceImpl(OutBoundDetailsMapper outBoundDetailsMapper) {
		this.outBoundDetailsMapper = outBoundDetailsMapper;
	}

	/**
     * 分页查询
     * @param params
     * @return
     */
	@Override
	public Page<OutBoundDetailsEntity> listOutBoundDetails(Map<String, Object> params) {
		Query query = new Query(params);
		Page<OutBoundDetailsEntity> page = new Page<>(query);
		outBoundDetailsMapper.listForPage(page, query);
		return page;
	}

	@Override
	public List<OutBoundDetailsEntity> listOutBoundDetailsNoPage(Map<String, Object> params) {
		Query query = new Query(params);
		return outBoundDetailsMapper.list(query);
	}

	/**
     * 新增
     * @param outBoundDetails
     * @return
     */
	@Override
	public R saveOutBoundDetails(OutBoundDetailsEntity outBoundDetails) {
		int count = outBoundDetailsMapper.save(outBoundDetails);
		return CommonUtils.msg(count);
	}

    /**
     * 根据id查询
     * @param id
     * @return
     */
	@Override
	public R getOutBoundDetailsById(Long id) {
		OutBoundDetailsEntity outBoundDetails = outBoundDetailsMapper.getObjectById(id);
		return CommonUtils.msg(outBoundDetails);
	}

    /**
     * 修改
     * @param outBoundDetails
     * @return
     */
	@Override
	public R updateOutBoundDetails(OutBoundDetailsEntity outBoundDetails) {
		int count = outBoundDetailsMapper.update(outBoundDetails);
		return CommonUtils.msg(count);
	}

    /**
     * 删除
     * @param id
     * @return
     */
	@Override
	public R batchRemove(Long[] id) {
		int count = outBoundDetailsMapper.batchRemove(id);
		return CommonUtils.msg(id, count);
	}

}
